package com.gandong8.trace.tool.config.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.ProducerListener;

@Slf4j
public class KafkaSendResultHandler implements ProducerListener {


    @Override
    public void onSuccess(ProducerRecord producerRecord, RecordMetadata recordMetadata) {
        log.warn("send_success:topic={},offset={},token={}",producerRecord.topic(), recordMetadata.offset(), producerRecord.key());
    }

    @Override
    public void onError(ProducerRecord producerRecord, Exception e) {
        log.warn("send_failed:topic={},token={},msg={},error={}", producerRecord.topic(), producerRecord.key(), producerRecord.value(),e.getMessage());
        e.printStackTrace();
    }
}
